import java.util.*;
public class Main {
public static void main(String[]args){
    Scanner sc=new Scanner(System.in);
    int a=sc.nextInt();
    String []A=new String[a];
    for(int i=0;i<a;i++){
        A[i]=sc.next();
    }
    int b=sc.nextInt();
    String []B=new String[b];
    for(int i=0;i<b;i++){
        B[i]=sc.next();
    }
    String []result=new String[101];
    Arrays.sort(A);
    Arrays.sort(B);
    int des=0,scr=0,count=0; //des-->A,scr-->B
    int n=Math.min(a,b);
    
    while(des<a&&scr<b){
        String StrA = A[des];
        String StrB = B[scr];
        int compareResult=StrA.compareTo(StrB);
         StrA=A[des];
         StrB=B[scr];
         compareResult=StrA.compareTo(StrB);
        if(compareResult>0){   //A>
            scr++;
        }
        else if(compareResult<0){
            des++;
        }
        else{
            result[count++]=StrA;
            des++;
            scr++;
        }
    }    
    for(int i=0;i<count;i++){
        System.out.printf("%s ",result[i]);
    } 
}
}
